home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
ned103.zip
/
NEWEDIT.DOC
< prev
next >
Wrap
Text File
|
1992-08-28
|
45KB
|
1,125 lines
INTRODUCTION
------------
I originally started this project to add a wordwrap feature to
the Turbo Vision EDITORS unit. To make matters worse, I'm new
to Pascal, and trying to learn the language, Turbo
Vision, and event driven programming was just a bit of a
hurdle. So I asked for help, LOTS of help, and the next thing
I knew I was working with people I've never met trying to
create a full-blown IDE compatible wordprocessor, with the
wordwrap!
Well, it got done, minus the IDE select text features such as
read/write/indent blocks, etc. If nothing else, it was one way
of learning three things at once. We all had a lot of fun,
probably at my expense <grin>.
NEWEDIT.PAS is a complete replacement for the original EDITORS
unit. It's major contribution is the implementation of a
wordwrap feature. It also has several other features, which
will be outlined below.
If you decide to use the NEWEDIT unit with your applications,
be sure you change your use clause from "uses Editors" to "uses
NewEdit" in all code modules that require the editor. Those
modules included in the NED103.ZIP file already do this.
You should NOT overwrite your original EDITORS.PAS file! Keep
it for reference should you decide to dig into the work I have
done and add your own features. Comparison is a learning tool!
The rest of this document deals with the modifications I have
made, discussing how they work, and whatever quirks you should
be familiar with. A command summary is also provided of all
the NEWEDIT options. Last of all, a brief discussion is given
that explains how to implement your own customized key
commands.
Please note that this document is NOT written for users. It is
written for you, the programmer. A lot of the information
contained herein would severely confuse your users due to its
technical nature. Don't make life harder on them by cutting
and pasting the current text to make a quick users guide. Take
the time and effort to write your own, and make it as simple as
possible.
HOW TO USE IT
-------------
I figured I'd put this right up front so you can jump right into it.
You can use the program either as is, or you can yank out NEWEDIT and
simply patch it into your application. I'll discuss both methods.
Using NEDEMO
------------
Your best bet is to create a directory and dump all the NED103.ZIP files
into it. Baring that, put the files wherever you want.
Next, ensure that all the units called in NEDEMO.PAS are available for
compilation. Now, compile the NEDEMO.PAS source. All the other units
will compile. If you get an error message stating that a unit can't be
compiled, fix your Options|Directories so the path to the unit is
correct. Or, take the unit TPU or PAS file and put it in your
compilation directory.
Plug Into Your Application
--------------------------
The NEWEDIT unit is plug-in compatible with the standard EDITORS unit.
If you're not interested in the NEDEMO program, but want to use the
NEWEDIT unit as is, you can easily patch it into your application.
You will need the EDITPKG.PAS and NEWEDIT.PAS programs. NEWEDIT.PAS is
the actual editor. EDITPKG.PAS contains all the dialogs and calls to
the clipboard and editor.
1) In your main application INIT constructor, insert this line BEFORE
you use "TApplication.Init":
EditPkg.Initialize_The_Editor;
Then load any previous desktop and disable any editor commands you
don't want the user to have immediate access to.
Last of all, initialize the clipboard with this code:
EditPkg.Initialize_The_Clipboard;
Look at the T_EditDemo.Init code in NEDEMO.PAS if you have
questions.
2) In your main application HandleEvent code, insert this line for
opening new files:
cmNew : EditPkg.Open_Editor ('', True);
3) In your main application HandleEvent code, insert this line for
opening existing disk files:
cmOpen : EditPkg.Run_The_Editor;
4) If you write the desktop to disk, for any reason, be sure you
deallocate and reallocate the clipboard. Failure to do so will
cause your desktop file to start growing and growing! Insert this
code around your save desktop code:
EditPkg.Deallocate_The_Clipboard;
{Your code goes here!}
EditPkg.Initialize_The_Clipboard;
If you have any questions on this, look in the NEDEMO.PAS
T_EditDemo.Save_Desktop function for how it should be done.
5) In your application's DONE destructor, be sure you deallocate the
editor buffer AFTER "TApplication.Done":
TApplication.Done;
EditPkg.Deallocate_The_Editor;
6) Check all units to ensure that "uses EDITORS" is changed to "uses
NEWEDIT".
7) If you want to use my help system, the EDITHELP.TXT file will
probably have to be revised to suit your hc???? constant naming
convention. That, or you'll have to write your own.
It's not as difficult as it sounds. I've done it with a minimum of
fuss, and several of the beta testers have done the same thing.
CREATING HELP
-------------
The file EDITHELP.TXT contains the source for the context sensitive help
system. You must compile it with the TVHC.EXE program to make it
functional. Included with NED103 is a MAKEHELP.BAT file. Simply type
MAKEHELP to generate a usable help file. Ensure that TVHC is in your
directory or path.
I've done things a bit different than normal here, so some explanation
might be in order.
All cm???? and hc???? constants are in the CMDFILE.PAS file. Seeing as
I've mixed these constants, I didn't want CMDFILE.PAS to be overwritten
by the TVHC program. What I do in the batch file is to let TVHC
generate an EDITHELP.PAS, EDITHELP.TPU, and EDITHELP.HLP file. I then
rename the EDITHELP.HLP file to NEDEMO.HLP and erase the EDITHELP.TPU
file. I keep the EDITHELP.PAS file as a handy alphabetical reference.
So, the short of it is that NEDEMO requires that the CMDFILE unit be
available and that the help file be named NEDEMO.HLP.
CODING STYLE
------------
Every one has their way of doing things, and I'm as guilty as the next
person. The only reason I bring it up is that coding style may look
very foreign to those who do it Borland's way. This is not a
justification, just an explanation!
I code the way I do so that I can quickly convert code between C,
PASCAL, and Ada.
I don't put all of my if/elses on one line. I like to see which
condition is met when I'm debugging.
I use lots of white space so things don't look as bad as they really
are<grin>.
I use 43/50 column mode and print in compressed mode, therefore my code
does tend to go beyond the right margin.
Last of all, and this is probably important to some of you, I use fully
qualified variable and procedure/function names. I HATE having to
figure out where a variable or procedure/function is. Where I work,
people are summarily shot for failing to do so!
WHEN IS A BUG NOT A BUG?
------------------------
When it's a feature, of course! I've seen several so-called bug
reports describing what the authors consider to be bugs in the
EDITORS unit, when in fact they are reporting features.
Granted, there are some bugs there, and the service these
authors provide by reporting them is invaluable.
To set the record straight, the following two items are NOT
bugs!
1) Pressing ^T will in some instances delete more than just the
word you want deleted.
Sorry, this is NOT a bug! The Editors unit defines a
particular character set. Any character not in that
character set is a "non-character". ^T works like this:
a) Delete from the cursor position all characters to the
first character not defined in our character set. That
takes care of the current word.
b) Now we need to delete all characters NOT in the
character set to the next character that IS in the
character set. That deletes the "blank space" between
words.
Step B